package com.zl.controller;

import com.zl.pojo.User;
import com.zl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/index/queryUserList")
    @ResponseBody
    public List<User>  queryUserList(){
        List<User> users = userService.queryUserList();
        for (User user : users) {
            System.out.println(user);
        }
        return users;
    }

    @RequestMapping("/index/addUser")
    @ResponseBody
    public String addUser(){
        int i = userService.addUser(new User(111, "小明", "123123"));
        return "OK";

    }

    @RequestMapping("/index/deleteUser")
    @ResponseBody
    public String deleteUser(){
        userService.deleteUser(1);
        return "OK";
    }
}
